using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Reflection;

namespace PantheonSoftware.InfoCollection
{
    /// <summary>
    /// This interface must be implemented by all InfoCollection classes. 
    /// It solves the problem of type independence in the base classes.
    /// </summary>
    /// <param name="T">The type of the item (Info class)</param>
    public interface IInfoCollection<T> : IBindingList, IList<T>
    {
        /// <summary>
        /// Calls the data layer and fills the collection with item objects.
        /// This is the default factory method (there can be overloads if necessary) and is the main business rule used to query a data source
        /// </summary>
        void Fill();
        /// <summary>
        /// Determines whether this instance has changes.
        /// </summary>
        /// <returns>
        /// 	<c>true</c> if this instance has changes; otherwise, <c>false</c>.
        /// </returns>
        bool HasChanges();
        /// <summary>
        /// Determines whether the instance has changes identfied by the supplied row state.
        /// </summary>
        /// <param name="rowStates">The row state to query.</param>
        /// <returns>
        /// 	<c>true</c> if the specified instance has changes; otherwise, <c>false</c>.
        /// </returns>
        bool HasChanges(DataRowState rowStates);
        /// <summary>
        /// Sorts this instance.
        /// </summary>
        void Sort();
        /// <summary>
        /// Sorts the instance in the specified direction.
        /// </summary>
        /// <param name="direction">The sort direction.</param>
        /// <param name="field">The field to sort on.</param>
        void Sort(ListSortDirection direction, PropertyInfo field);
        /// <summary>
        /// Sorts the instance in the specified direction.
        /// </summary>
        /// <param name="direction">The sort direction.</param>
        void Sort(ListSortDirection direction);
        /// <summary>
        /// Gets or sets the sort property.
        /// </summary>
        /// <value>The sort property.</value>
        string SortBy { get; set; }
        /// <summary>
        /// Gets the underlying DataTable object.
        /// </summary>
        /// <value>The table.</value>
        DataTable Table { get; }
        /// <summary>
        /// Undoes the changes made to this collection.
        /// </summary>
        void Undo();
        //// <summary>
        //// Default Update routine to persist the changes made to the
        //// collection.
        //// </summary>
        //// <returns>
        //// A DataSet of updated rows.
        //// </returns>                                               
        DataSet Update();
        //// <summary>
        //// Default Update routine to persist the changes made to the
        //// collection.
        //// 
        //// Takes an UpdateType parameter which can be:
        //// 
        //// <b>SingleUpdate</b>: The update will perform an update only
        //// \on the current collection
        //// 
        //// <b>RecursiveUpdate</b>: The update will drill down into
        //// sub-collections. No transaction is started.
        //// 
        //// <b>SingleUpdateWithTransaction</b>: The update will update
        //// \only this collection and will start/complete a transaction
        //// 
        //// <b>RecursiveUpdateWithTransaction</b>: This update will
        //// drilldown into a sub-collection. A transaction will be
        //// started across objects.
        //// </summary>
        //// <param name="ut">The UpdateType</param>
        //// <returns>
        //// A DataSet of updated records
        //// </returns>                                                 
        DataSet Update(UpdateType ut);
        //// <summary>
        //// Default Update routine to persist the changes made to the
        //// collection.
        //// 
        //// Takes an UpdateType parameter which can be:
        //// 
        //// <b>SingleUpdate</b>: The update will perform an update only
        //// \on the current collection
        //// 
        //// <b>RecursiveUpdate</b>: The update will drill down into
        //// sub-collections. No transaction is started.
        //// 
        //// <b>SingleUpdateWithTransaction</b>: The update will update
        //// \only this collection and will start/complete a transaction
        //// 
        //// <b>RecursiveUpdateWithTransaction</b>: Ths update will
        //// drilldown into a sub-collection. A transaction will be
        //// started across objects.
        //// </summary>
        //// <param name="ut">The UpdateType</param>
        //// <returns>
        //// A DataSet of updated records
        //// </returns>                                                 
        DataSet Update(IDbManager dbManager, UpdateType ut);
    }
}
